Imports System.Collections
Imports System.IO

Partial Public Class frmConsultaArquivos
    Inherits System.Web.UI.Page
    Dim nomeArquivo As String


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim infoDir As New DirectoryInfo(Server.MapPath("/icli/uploads/"))
            Dim files As FileInfo()
            Dim l As New ListItemCollection

            files = infoDir.GetFiles("*.*")

            For Each f As FileInfo In files
                If f.Extension = ".jpg" Or f.Extension = ".gif" Or f.Extension = ".jpeg" Then
                    ListBox1.Items.Add(f.Name)
                End If
            Next

            'ListBox1.DataSource = infoDir.GetFiles("*.*")
            'ListBox1.DataSource = l
            'ListBox1.DataBind()

        End If

    End Sub

    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Image1.ImageUrl = "/icli/uploads/" & ListBox1.SelectedItem.Text
        'Image1.Attributes("src") = "/Site/uploads/" & ListBox1.SelectedItem.Text
    End Sub

    Protected Sub btnSelecionar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelecionar.Click
        Response.Write("<script language='javascript'>")
        Response.Write(" window.opener.document.getElementById('hdIDObj').value='" & Request("path") & ListBox1.SelectedItem.Text & "';")
        Response.Write(" window.opener.execScript(""__doPostBack('Arquivo','')"");")
        Response.Write(" window.close();")
        Response.Write("</script>")
    End Sub

End Class